from flask import Flask, request, render_template
from werkzeug.datastructures import CombinedMultiDict
import os

from forms_cherk import UploadForm

UPLOAD_PATH = os.path.join(os.path.dirname(__file__), 'imgs')

app = Flask(__name__)


@app.route('/upload/', methods=['GET', 'POST'])
def upload():
    if request.method == 'GET':
        return render_template('index.html')
    else:
        form = UploadForm(CombinedMultiDict([request.form,request.files]))
        if form.validate():

            return '上传成功'
        else:
            return f'{form.errors}'

if __name__ == '__main__':
    app.run(debug=True)
